//
//  LayoutS5ViewController.m
//  OASDK_Works
//
//  Created by ChenJie on 3/16/20.
//  Copyright © 2020 Mist. All rights reserved.
//

#import "LayoutS5ViewController.h"

@interface LayoutS5ViewController ()

@property (nonatomic, strong) UIView *node1;
@property (nonatomic, strong) UIView *node11;
@property (nonatomic, strong) UIView *node111;
@property (nonatomic, strong) UIView *node112;
@property (nonatomic, strong) UIView *node12;
@property (nonatomic, strong) UIView *node2;
@property (nonatomic, strong) UIView *node3;

@end

@implementation LayoutS5ViewController

#pragma mark - ViewController lifecycle

- (instancetype)init {
    self = [super init];
    if (self) {
        self.layoutDirection = DirectionRow;
        self.layoutJustifyContent = JustifyContentFlexStart;
        self.layoutAlignItems = AlignItemsFlexStart;
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationItem.title = NSStringFromClass(self.class);
    
    [self.layoutContainer addSubview:self.node1];
    [self.node1 addSubview:self.node11];
    [self.node11 addSubview:self.node111];
    [self.node11 addSubview:self.node112];
    [self.node1 addSubview:self.node12];
    [self.layoutContainer addSubview:self.node2];
    [self.layoutContainer addSubview:self.node3];
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
}

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
}

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
}

- (void)viewDidDisappear:(BOOL)animated {
    [super viewDidDisappear:animated];
}

- (void)viewWillLayoutSubviews {
    [super viewWillLayoutSubviews];
}

- (void)viewDidLayoutSubviews {
    [super viewDidLayoutSubviews];
    
    //
}

- (UIStatusBarStyle)preferredStatusBarStyle {
    return UIStatusBarStyleLightContent;
}

#pragma mark - Public methods

- (void)setupLayout:(OADLayout5 *)layout {
    
    //
    layout.marginLeft = 10;
    layout.marginTop = 15;
    layout.marginRight = 20;
    layout.marginBottom = 15;
    
    layout.width = 350;
    layout.height = 350;
    
    //
    OADLayout5 *node1 = [OADLayout5 new];
    node1.name = @"node1";
    
    node1.direction = DirectionRow;
    node1.justifyContent = JustifyContentCenter;
    node1.alignItems = AlignItemsCenter;
    
    node1.marginLeft = 5;
    node1.marginTop = 5;
    node1.marginRight = 5;
    node1.marginBottom = 5;
    
//    node1.width = 155;
//    node1.height = 80;
    node1.grow = 1;
    
    [layout addNode:node1];
    
    //
    OADLayout5 *node11 = [OADLayout5 new];
    node11.name = @"node11";
    
    node11.direction = DirectionColumn;
    node11.justifyContent = JustifyContentSpaceAround;
    node11.alignItems = AlignItemsCenter;
    
    node11.marginLeft = 5;
    node11.marginTop = 15;
    node11.marginRight = 5;
    node11.marginBottom = 35;
    
//    node11.width = 30;
//    node11.height = 40;
    node11.grow = 1;
    
    [node1 addNode:node11];
    
    //
    OADLayout5 *node111 = [OADLayout5 new];
    node111.name = @"node111";

    node111.marginLeft = 5;
    node111.marginTop = 5;
    node111.marginRight = 5;
    node111.marginBottom = 5;

    node111.width = 50;
    node111.height = 60;
    node111.grow = 1;

    [node11 addNode:node111];
    
    //
    OADLayout5 *node112 = [OADLayout5 new];
    node112.name = @"node112";

    node112.marginLeft = 5;
    node112.marginTop = 5;
    node112.marginRight = 5;
    node112.marginBottom = 5;

    node112.width = 70;
    node112.height = 80;
    node112.grow = 1;

    [node11 addNode:node112];
    
    //
    OADLayout5 *node12 = [OADLayout5 new];
    
    node12.name = @"node12";
    node12.marginLeft = 5;
    node12.marginTop = 15;
    node12.marginRight = 5;
    node12.marginBottom = 35;
    
    node12.width = 30;
    node12.height = 40;
    node12.grow = 1;

    [node1 addNode:node12];
    
    //
    OADLayout5 *node2 = [OADLayout5 new];
    node2.name = @"node2";
    
    node2.marginLeft = 5;
    node2.marginTop = 5;
    node2.marginRight = 5;
    node2.marginBottom = 5;
    
    node2.width = 40;
    node2.height = 50;
    node2.grow = 1;
    
    [layout addNode:node2];
    
    //
    OADLayout5 *node3 = [OADLayout5 new];
    node3.name = @"node3";
    
    node3.marginLeft = 5;
    node3.marginTop = 5;
    node3.marginRight = 5;
    node3.marginBottom = 5;
    
    node3.width = 50;
    node3.height = 60;
    
    [layout addNode:node3];
    
}

#pragma mark - Private methods



#pragma mark - Event response methods



#pragma mark - Deletate methods



#pragma mark - Setter



#pragma mark - Getter

- (UIView *)node1 {
    if (!_node1) {
        UIView *view = [UIView new];
        view.layoutName = NSStringFromSelector(_cmd);
        _node1 = view;
    }
    return _node1;
}

- (UIView *)node11 {
    if (!_node11) {
        UIView *view = [UIView new];
        view.layoutName = NSStringFromSelector(_cmd);
        _node11 = view;
    }
    return _node11;
}

- (UIView *)node111 {
    if (!_node111) {
        UIView *view = [UIView new];
        view.layoutName = NSStringFromSelector(_cmd);
        _node111 = view;
    }
    return _node111;
}

- (UIView *)node112 {
    if (!_node112) {
        UIView *view = [UIView new];
        view.layoutName = NSStringFromSelector(_cmd);
        _node112 = view;
    }
    return _node112;
}

- (UIView *)node12 {
    if (!_node12) {
        UIView *view = [UIView new];
        view.layoutName = NSStringFromSelector(_cmd);
        _node12 = view;
    }
    return _node12;
}

- (UIView *)node2 {
    if (!_node2) {
        UIView *view = [UIView new];
        view.layoutName = NSStringFromSelector(_cmd);
        _node2 = view;
    }
    return _node2;
}

- (UIView *)node3 {
    if (!_node3) {
        UIView *view = [UIView new];
        view.layoutName = NSStringFromSelector(_cmd);
        _node3 = view;
    }
    return _node3;
}

#pragma mark - Memory management

- (void)dealloc {
}

@end
